<%-- 
    Document   : cart.jsp
    Created on : 27 avr. 2011, 16:29:53
    Author     : simon
--%>
<%@ taglib prefix="myTags" uri="/WEB-INF/tlds/tagsutil" %>
<c:set var="view" value="/cart" scope="session"/>


<div id="content">

    <div id="actionBar">
        <span class="rounded bubble"><a href="<c:url value='cart'><c:param name='clear' value='true' /></c:url>"><fmt:message key="actionEmpty"/></a></span>
        <span id="" class="rounded bubble"><a href="authenticate"><fmt:message key="actionCheckout"/></a></span>
    </div>

    <c:choose>
        <c:when test="${cart.numberOfItems > 1}">
            <p><fmt:message key="yourCartContains"/> ${cart.numberOfItems} <fmt:message key="items"/>.</p>
        </c:when>
        <c:when test="${cart.numberOfItems == 1}">
            <p><fmt:message key="yourCartContains"/> ${cart.numberOfItems} <fmt:message key="item"/>.</p>
        </c:when>
        <c:otherwise>
            <p><fmt:message key="yourCartEmpty"/></p>
        </c:otherwise>
    </c:choose>

    <c:if test="${!empty cart && cart.numberOfItems != 0}">

        <h4 id="subtotal" class="infoH4"><fmt:message key="subtotal"/>:
            <myTags:price price='${cart.subtotal}' localString="${language}"></myTags:price>
        </h4>

        <h4 id="subtotal" class="infoH4"><fmt:message key="cartContent"/>:</h4>
        <table id="cartTable" class="rounded shadow">

            <c:forEach var="item" items="${cart.items}" varStatus="iter">

                <c:set var="product" value="${item.product}"/>

                <tr class="">
                    <td>
                <c:forEach items="${product.imageList}" var="image">
                    <c:if test="${ fn:contains(image.url, 'etiquette') }">
                        <img src="/ecom-web/icon/products/${image.url}" alt="image" />
                    </c:if>
                </c:forEach>
                </td>

                <td>${product.name}</td>

                <td>
                    <myTags:price price='${item.total}' localString="${language}"></myTags:price>
                <br>
                <span class="smallText">(
                    <myTags:price price='${item.price}' localString="${language}"></myTags:price>
                    / <fmt:message key="unit"/>)</span>
                </td>

                <td>
                    <form action="<c:url value='updateCart'/>" method="post">
                        <input type="hidden"
                               name="productId"
                               value="${product.idProduct}">
                        <input type="hidden"
                               value="${item.storeId}"
                               name="storeId"
                               style="margin:5px">
                        <input type="text"
                               maxlength="2"
                               size="2"
                               value="${item.quantity}"
                               name="quantity"
                               style="margin:5px">
                        <input type="submit"
                               name="submit"
                               value="<fmt:message key='update'/>">
                    </form>
                </td>
                </tr>
            </c:forEach>
        </table>
    </c:if>
</div>
